﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Login : System.Web.UI.Page
{
    Bank.User _user;
    Bank.Balance _balance;
    protected void Page_Load(object sender, EventArgs e)
    {
        _user = new Bank.User();
        int userid = -1;
        try
        {
            userid = Convert.ToInt32(Session["userid"].ToString());
        }
        catch (Exception)
        {
            userid = -1;
        }
        if (userid > 0)
        {
            MultiView1.ActiveViewIndex = 1;
            Label2.Text = _user.getusername(userid);

            _balance = new Bank.Balance();
            DataSet ds = _balance.getBalanceInfo(userid);
            Label3.Text = ds.Tables[0].Rows[0]["BalanceUSD"].ToString();
            Label4.Text = ds.Tables[0].Rows[0]["BankName"].ToString();
            
        }
        else
        {
            MultiView1.ActiveViewIndex = 0;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Session["userid"] = _user.login(TextBox1.Text, TextBox2.Text);
        Response.Redirect(Request["URL"]);
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Session["userid"] = -1;
        Response.Redirect(Request["URL"]);
    }
}
